package com.naiterui.ehp.bs.doctor.controller;

import com.naiterui.ehp.bp.constants.SwaggerTag;
import com.naiterui.ehp.bp.constants.SwaggerTags;
import com.naiterui.ehp.bp.support.exception.BusinessException;
import com.naiterui.ehp.bp.support.exception.PublicService;
import com.naiterui.ehp.bp.support.exception.ResponseVO;
import com.naiterui.ehp.bs.doctor.exception.ExceptionCodes;
import com.naiterui.ehp.bs.doctor.service.IPatientRecordService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 患者病历控制类
 *
 * @version 2015年6月21日 下午6:03:39 by chenlin
 * @Description 概述
 */
@Controller
@RequestMapping("ad/patientRecord")
@Api(tags = {SwaggerTag.DOCTOR + SwaggerTag.MEDICINE_DRUG})
public class AdPatientRecordController {

    private static final Logger LOGGER = LoggerFactory.getLogger(AdPatientRecordController.class);
    @Autowired
    private IPatientRecordService patientRecordService;


    /**
     * 提醒患者发送病历
     * PatientRecordController.remindPatientSendRecord()
     *
     * @param patientId
     *
     * @return
     *
     * @throws BusinessException
     * @Author lichaopi
     * @Date 2018年6月1日
     * @since 1.0.0
     */
    @ApiOperation(value = "提醒患者发送病历", httpMethod = "POST")
    @ApiImplicitParams({ @ApiImplicitParam(name = "doctorId", value = "医生ID", required = true, dataType = "long", paramType = "query"),
            @ApiImplicitParam(name = "patientId", value = "患者ID", required = true, dataType = "long", paramType = "query"), })
    @RequestMapping("remindPatient")
    @ResponseBody
    public ResponseVO<Void> remindPatientSendRecord(Long patientId, Long doctorId) throws BusinessException {
        LOGGER.info("提醒患者发送病历,请求参数,doctorId:{},patientId:{}", doctorId, patientId);
        boolean verify = PublicService.paramsHasNull(doctorId, patientId);
        if (verify) {
            LOGGER.error("提醒患者发送病历,请求参数为空,doctorId:{},patientId:{}", doctorId, patientId);
            throw new BusinessException(ExceptionCodes.PARAM_ERROR);
        }
        this.patientRecordService.remindPatientSendRecord(doctorId, patientId);
        return PublicService.returnResponseVO(ExceptionCodes.SUCCESS);
    }
}
